package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.project;

import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;


/**
 * 项目系统关联表
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_it_project_system_relation set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_it_project_system_relation set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_it_project_system_relation", indexes = {@Index(name = "UK_PRO_SYS_DEL", columnList = "project_no, system_class_no, deleted", unique = true)})
public class ProjectSystemRelation extends BaseEntity {

    private static final long serialVersionUID = 1443712956914371358L;

    @Column(name = "project_no", columnDefinition = "varchar(128) not null comment '项目编号'")
    private String projectNo;

    @Column(name = "system_class_no", columnDefinition = "varchar(128) not null comment '项目名称'")
    private String systemClassNo;

}

